package com.chenchao.net;

import java.io.IOException;
import java.net.*;

/**
 * @encoding : UTF-8
 * @Time : 2020/11/25 20:40
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.net.Test09B.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 *组播发送方
 */
public class Test09B {
    public static void main(String[] args) throws IOException {
        /*选码头*/
        DatagramSocket socket = new DatagramSocket();
        /*建集装箱*/
        InetAddress address = InetAddress.getByName("224.0.1.0");
        String s= "农民兄弟们，起义时刻到了";

        /*装箱写组播地址*/
        DatagramPacket dp = new DatagramPacket
                (s.getBytes(),s.getBytes().length,address,10000);
        /*开船*/
        socket.send(dp);
        /*关码头*/
        socket.close();
    }
}
